﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="EyeOpen.DataDriven.Web._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Eye.Open - DataDriven - Web</title>
</head>
<body>
    <form id="mainForm" runat="server">
    <div>
        <asp:ObjectDataSource ID="personListObjectDataSource" runat="server" 
            TypeName="EyeOpen.DataDriven.Web.PersonDataSource"
            DataObjectTypeName="EyeOpen.DataDriven.Domain.Person"
            SelectMethod="GetAll" 
            DeleteMethod="Delete" 
            InsertMethod="Insert"
            UpdateMethod="Update"         
        />
        <asp:GridView ID="personListGridView" runat="server" 
            AutoGenerateColumns="False" 
            DataSourceID="personListObjectDataSource"
            DataKeyNames="Id" 
            AutoGenerateDeleteButton="True" 
            onrowdeleted="PersonListGridView_RowDeleted" onselectedindexchanged="PersonListGridView_SelectedIndexChanged"
        >
            <Columns>
                <asp:TemplateField ShowHeader="False">
                    <ItemTemplate>
                        <asp:LinkButton runat="server" 
                            CausesValidation="False" 
                            CommandName="Select" 
                            Text="Edit" 
                        />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" />
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                <asp:BoundField DataField="Surname" HeaderText="Surname" SortExpression="Surname" />
                <asp:BoundField DataField="Age" HeaderText="Age" SortExpression="Age" />
            </Columns>
        </asp:GridView>
        <br />
        <asp:ObjectDataSource ID="personDetailObjectDataSource" runat="server" 
            TypeName="EyeOpen.DataDriven.Web.PersonDataSource" 
            DataObjectTypeName="EyeOpen.DataDriven.Domain.Person"
            SelectMethod="Get" 
            DeleteMethod="Delete" 
            InsertMethod="Insert" 
            UpdateMethod="Update"
        >
            <SelectParameters>
                <asp:ControlParameter 
                    ControlID="personListGridView" 
                    Name="id" 
                    PropertyName="SelectedValue"
                    Type="Object" 
                />
            </SelectParameters>
        </asp:ObjectDataSource>
        <asp:DetailsView ID="personDetailsView" runat="server" 
            AutoGenerateRows="False" 
            DataKeyNames="Id"
            DataSourceID="personDetailObjectDataSource" 
            AutoGenerateEditButton="True" 
            AutoGenerateInsertButton="True" ondatabound="PersonDetailsView_DataBound" 
            oniteminserted="PersonDetailsView_ItemInserted" onitemupdated="PersonDetailsView_ItemUpdated"
        >
            <Fields>
                <asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" />
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                <asp:BoundField DataField="Surname" HeaderText="Surname" SortExpression="Surname" />
                <asp:BoundField DataField="Age" HeaderText="Age" SortExpression="Age" />
            </Fields>
        </asp:DetailsView>
    </div>
    </form>
</body>
</html>